package org.aiforum.frountend.service;

import java.util.Date;

import javax.transaction.Transactional;
import javax.transaction.Transactional.TxType;

import org.aiforum.domain.Contact;
import org.aiforum.frountend.common.Response;
import org.aiforum.frountend.dao.ContactDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 联系我们业务实现
 * @author VIC
 *
 */
@Service("contactService")
@Transactional(value=TxType.REQUIRED)
public class ContactServiceImpl implements ContactService {
	
	@Autowired
	private ContactDao contactDao;

	@Override
	public Response save(Contact entity) {
		
		// 设置状态和创建日期
		entity.setState(1);
		entity.setCreateDate(new Date());
		
		contactDao.persist(entity);
		
		Response response = new Response();
		response.setState(true);
		response.setData("<script>window.location.href='message?message=Send success.';</script>");
		response.setMessage("Send success.");
		
		return response;
	}

}
